<template>
  <div>
<h1>用户列表</h1>
投资项目名称：<input type="text" v-model="state.TName">
<input type="button" value="查询" @click="usershow">
<table>
  <tr>
    <td>投资id</td>
    <td>投资项目名称</td>
    <td>总额度</td>
    <td>已投金额</td>
    <td>剩余金额</td>
    <td>投资次数</td>
  </tr>
  <tr v-for="item in list">
    <td>{{item.Tid}}</td>
    <td>{{item.TName}}</td>
    <td>{{item.TMoney}}</td>
    <td>{{item.TYiTou}}</td>
    <td>{{item.TShengYu}}</td>
    <td>{{item.CiShu}}</td>
  </tr>
</table>
<input type="button" value="首页" @click="page(1)">
<input type="button" value="上一页" @click="page(state.pageIndex-1)">
<input type="button" value="下一页" @click="page(state.pageIndex+1)">
<input type="button" value="尾页" @click="page(pcount)">
<input type="text" size="5">
<input type="button" value="Go" @click="page(pcount)" >
  </div>
</template>

<script setup lang="ts">
import {reactive,toRefs,onMounted} from 'vue'
import axios from 'axios'
import {useRoute,useRouter} from 'vue-router'
const route=useRoute()
const router=useRouter()

let data:any=reactive({
  list:[],
  state:{
     TName:'',
     pageIndex:1,
     pageSize:2
  },
  count:0,
  pcount:0
})

let {list,state,count,pcount}=toRefs(data)

onMounted(()=>{
  usershow()
})

const usershow=()=>{
axios({
  url:'/api/TouZi/GetUserShow',
  method:'get',
  params:state.value
})
.then(res=>{
  list.value=res.data.data.plist;
  count.value=res.data.data.count;
  pcount.value=res.data.data.pcount;
})
.catch(err=>{
 console.log(err);
})
}

const page=(y:any)=>{
   if(y>=1 && pcount.value>=y){
    state.value.pageIndex=y;
   }
   usershow()
}
</script>

<style scoped>

</style>